package com.bkgrands.fpmu.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.bkgrands.fpmu.Adapters.MstagesAdapter;
import com.bkgrands.fpmu.R;
import com.bkgrands.fpmu.classes.StaticFarm;

public class MstagesActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    MstagesAdapter adapter;
    public static String majorname;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_majorsites);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        Intent startingIntent = getIntent();
        majorname= startingIntent.getStringExtra("facility");
        getSupportActionBar().setTitle(majorname);

        initViews();
    }

    private void initViews(){
        recyclerView = (RecyclerView)findViewById(R.id.item_recycler_view);
        recyclerView.setHasFixedSize(true);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
        recyclerView.setLayoutManager(layoutManager);
        loadJSON();
    }

    private void loadJSON() {
   //     if (StaticFarm.responseAtLogin.getPayload().get(1).getFacility().equals(name)) {
            adapter = new MstagesAdapter(getApplicationContext(), StaticFarm.currentSite.getMstages());
            StaticFarm.mstageAdapter = adapter;
            recyclerView.setAdapter(adapter);
   //     }
    }



}



